﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PowersourceUIToolkit;


namespace UCL.Powersource
{
    public interface IPowersourceExt 
    {
        IReportingManager ReportingManager { get; }
        IStatisticManager StatisticManager { get; }
        IUIManager UIManager { get; }
        ILog Log { get; }
        //T Get<T>();
        //object GetInstance(Type t, string key=null);
        //IEnumerable<object> GetAllInstances(Type t);
    }

    
    public static class PowersourceConnector
    {
        private static IPowersourceExt _IPowersourceExt;
        public static IPowersourceExt GetExtensibilityPoint()
        {
            if (_IPowersourceExt == null) throw new InvalidOperationException("Bootstrapper has not been initialized. You cannot access ExtensibilityPoint before initilizing the bootstrapper.");
            return _IPowersourceExt;
        }

        public static void Configure(IPowersourceExt ext)
        {
            if (_IPowersourceExt != null) throw new InvalidOperationException("Extensibility point already set. Once PowersourceExtensibility is configured it cannot be reconfigured");
            IoC.BuildUp(ext);
            _IPowersourceExt = ext;
        }

        internal static void CleanUp()
        {
            _IPowersourceExt = null;
        }

       
    }
}
